﻿using Hangfire.HttpJob.Agent;
using Hangfire.HttpJob.Agent.Attribute;

namespace HttpJobAgentTest11;


[SingletonJob(RegisterName = "单例job")]//不打这个标签也行 默认就是单例的
public class TestJob: JobAgent
{
    public TestJob(ILogger<TestJob> logger)
    {
        logger.LogInformation($"Create {nameof(TestJob)} Instance Success");
    }

    public override async Task OnStart(JobContext jobContext)
    {
       jobContext.Console.WriteLine("开始等待10秒");

       await Task.Delay(1000 * 10);
       
       jobContext.Console.WriteLine("结束等待10秒");
       
       jobContext.Console.WriteLine("开始测试Progressbar",ConsoleFontColor.Cyan);


       var bar = jobContext.Console.WriteProgressBar("testbar");

       for (int i = 0; i < 100; i++)
       {
           bar.SetValue(i);

           await Task.Delay(1000);
       }


    }
}